/*
 * Created on 26/04/2008
 * 
 */
package com.apbetioli.mapr.project.entity;

import com.apbetioli.mapr.project.schema.CtFlickrData;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 *
 * @author Alexandre Parra Betioli
 */
@Embeddable
public class FlickrData extends CtFlickrData implements Serializable {

    /*---------------------------------------------*/
    // Columns
    /*---------------------------------------------*/
    
    @Column( name="FLICKR_USERID" )    
    @Override
    public String getUserId() {
        return super.getUserId();
    }
    
    @Column( name="FLICKR_PHOTOSETID" )    
    @Override
    public String getPhotosetId() {
        return super.getPhotosetId();
    }

    /*---------------------------------------------*/
    // Methods
    /*---------------------------------------------*/
    
    public void parse( final CtFlickrData ctFlickrData ) {
        if( ctFlickrData == null)
            throw new IllegalArgumentException("FlickrData is null.");
            
        this.setUserId    ( ctFlickrData.getUserId() );
        this.setPhotosetId( ctFlickrData.getPhotosetId() );
    }
    
    @Override
    public int hashCode() {
        String hash = "" + getUserId() + getPhotosetId();
        return hash.hashCode();
    }

    @Override
    public boolean equals(Object object) {

        if( object == null )
            return false;
        
        if (!(object instanceof FlickrData))
            return false;
        
        FlickrData other = (FlickrData) object;
        
        if (( !this.getUserId().equals(other.getUserId())  )  ||
            ( !this.getPhotosetId().equals(other.getPhotosetId()) )) {
            return false;
        }
        
        return true;
    }
    
    @Override
    public String toString() {
        return "FlickrData[User ID=" + getUserId() + ", Photoset ID=" + getPhotosetId() + "]";
    }

    @Override
    public FlickrData clone() {
        
        FlickrData fd = new FlickrData();
        fd.setUserId( this.getUserId() );
        fd.setPhotosetId( this.getPhotosetId() );
        
        return fd;
    }
    
}
